<template>
  <div :class="content">
    <el-form :model="form" ref="form" label-width="100px" class="demo-ruleForm">
      <!-- 1 -->
      <el-row>
        <el-col :span="8">
          <el-form-item label="编号">
            <el-input v-model="form.customer_id"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="客户名称">
            <el-input v-model="form.customer"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="联系人">
            <el-input v-model="form.contact"></el-input>
          </el-form-item>
        </el-col>
      </el-row>

      <!-- 2 -->
      <el-row>
        <el-col :span="8">
          <el-form-item label="售后分类">
            <el-select v-model="form.a_s_type" placeholder="请选择">
              <el-option
                v-for="(item, index) in categoryList"
                :key="index"
                :label="item.name"
                :value="item.id"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="反馈主题">
            <el-input v-model="form.a_s_topic"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="备注">
            <el-input v-model="form.a_s_remark"></el-input>
          </el-form-item>
        </el-col>
      </el-row>

      <!-- 3 -->
      <el-row>
        <el-col :span="8">
          <el-form-item label="反馈时间">
            <el-col :span="11">
              <el-date-picker
                type="date"
                placeholder="选择日期"
                v-model="form.feedback_time"
                style="width: 100%"
              ></el-date-picker>
            </el-col>
            <el-col class="line" :span="2"> ~ </el-col>
            <el-col :span="11">
              <el-date-picker
                type="date"
                placeholder="选择日期"
                v-model="form.feedback_time01"
                style="width: 100%"
              ></el-date-picker>
            </el-col>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="结束日期">
            <el-col :span="11">
              <el-date-picker
                type="date"
                placeholder="选择日期"
                v-model="form.disposal_time"
                style="width: 100%"
              ></el-date-picker>
            </el-col>
            <el-col class="line" :span="2">~</el-col>
            <el-col :span="11">
              <el-date-picker
                type="date"
                placeholder="选择日期"
                v-model="form.disposal_time01"
                style="width: 100%"
              ></el-date-picker>
            </el-col>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="售后状态">
            <el-select v-model="form.a_s_state" placeholder="请选择">
              <el-option
                v-for="(item, index) in typeList"
                :key="index"
                :label="item.name"
                :value="item.id"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>

      <!-- 4 -->
      <el-row>
        <el-col :span="8">
          <el-form-item label="业务员">
            <el-select v-model="form.a_s_employee" placeholder="请选择">
              <el-option
                v-for="(item, index) in employee"
                :key="index"
                :label="item.employee_name"
                :value="item.employee_id"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <!-- <el-col :span="8">
          <el-form-item label="自定义字段">
            <el-input v-model="form.reserved"></el-input>
          </el-form-item>
        </el-col> -->
      </el-row>

      <!-- 底部按钮 -->
      <el-row :class="btn">
        <el-col>
          <el-button type="primary" @click="submitForm" plain
            >立即搜索</el-button
          >
          <el-button type="warning" @click="resetForm" plain
            >清空条件</el-button
          >
          <el-button type="info" @click="exportForm" plain>导出数据</el-button>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>

<script>
import { mapMutations } from "vuex";
import { afterSaleEmpAxios } from "../../http/apis/afterSaleApi";
// import { timeFormat } from "../../utils/utils";

export default {
  name: "SearchItem",
  data() {
    return {
      form: {
        // reserved: "", //自定义字段
        customer_id: "", //编号
        customer: "", //客户名称
        contact: "", //联系人
        a_s_topic: "", //反馈主题
        a_s_remark: "", //备注
        a_s_type: "", //售后分类
        a_s_state: "", //售后状态
        a_s_employee: "", //业务员
        feedback_time: "", //反馈时间开始
        feedback_time01: "", //反馈时间结束
        disposal_time: "", //结束日期开始
        disposal_time01: "", //结束日期结束
      },
      // 初始化拷贝
      defaultUserFormSearch: {},
      // 业务员列表
      employee: [{ employee_id: 1, employee_name: "业务员" }],
      categoryList: [
        { id: 1, name: "其他问题" },
        { id: 2, name: "操作问题" },
        { id: 3, name: "产品质量" },
      ],

      // 状态分类列表
      typeList: [
        {
          id: 1,
          name: "未处理",
        },
        {
          id: 2,
          name: "处理中",
        },
        {
          id: 3,
          name: "已处理",
        },
      ],
      btn: "btn",
      content: "content",
    };
  },
  props: {
    // typeList:Array,
  },
  methods: {
    ...mapMutations("afterSaleStore", ["setHighSearch"]),

    //搜索
    submitForm() {
      console.log(this.form);
      this.setHighSearch(this.form);
    },

    //重置
    resetForm() {
      this.form = JSON.parse(JSON.stringify(this.defaultUserFormSearch));
      // this.defaultUserFormSearch;
      // this.setHighSearch(this.form);
    },

    exportForm() {}, //导出

    getEmp() {
      afterSaleEmpAxios()
        .then((res) => {
          console.log("员工", res.data);
          if (res.data.code == 200) {
            this.employee = res.data.data;
            // this.getNewData(res.data);
          }
        })
        .catch((err) => {
          console.log("请求失败：", err);
        });
    },
  },
  created() {
    this.defaultUserFormSearch = JSON.parse(JSON.stringify(this.form));
    this.getEmp();
  },
};
</script>

<style lang="scss" scoped>
.content {
  margin: 20px 10px;
}
.btn {
  text-align: center;
}
.el-col {
  overflow: initial;
}
</style>